#ifndef __PSRFOLD_H__
#define __PSRFOLD_H__

#include <complex.h>
#include <fftw3.h>
#include <math.h>
#include <stdlib.h>

#define nbin 1024

long get_period_size(float bw);

void apply_chirp(fftw_complex *fdata,float bw,float fc,long size);

void fft(fftw_complex *in,fftw_complex *out,long size);

void ifft(fftw_complex *in,double *out,long size);

void ifft_c2c(fftw_complex *in,fftw_complex *out,long size);

void amplitude(double *amp1,double *amp2,double *out,long size); 

void compute_amplitude(fftw_complex *fdata,double * out,long size);

void extract_subband(fftw_complex *data,fftw_complex *subband,long size,int nfft,int index);

void extract_freq(fftw_complex *freq,long size,long *valid_size,long *start,int index,int nfft);

void shift_freq(fftw_complex *freq,long size);

void flip_freq(fftw_complex *freq,long size);

void combine_freq(fftw_complex * full_freq,fftw_complex * sub_time,int index,int nfft,long size);

void coherent_dedispersion(fftw_complex *pol1,fftw_complex *pol2,double *out,float bw,float fc,long size,int index,int nfft);

void dedispersion_fold(fftw_complex *subband1,fftw_complex *subband2,double *pdata,double *pnum,long *location,int nfft,long psize,long size);

void fold_data(double *pdata,double *pnum,double *bdata,long psize,long blocksize,long *location);

void integral_data(double *data,double *out,long size);

void offset_data(double *data,double *out,double phi);

#endif